<?php $this->load->module('mobile/index/header', $common);?>
<link rel="stylesheet" type="text/css" href="<?php echo URLPRE;?>static/template/default/mobile/css/main.css" />
<link rel="stylesheet" type="text/css" href="<?php echo URLPRE;?>static/template/default/mobile/css/dialog.css" />
<link rel="stylesheet" type="text/css" href="<?php echo URLPRE;?>static/template/default/mobile/css/base.css" />
<link rel="stylesheet" type="text/css" href="<?php echo URLPRE;?>static/template/default/mobile/css/index.css" />
<link rel="stylesheet" type="text/css" href="<?php echo URLPRE;?>static/template/default/mobile/css/line.css" />
<script type="text/javascript" src="<?php echo URLPRE;?>static/template/default/mobile/js/mobilecommon.js"></script>
<script type="text/javascript" src="<?php echo URLPRE;?>static/template/default/mobile/js/slider.js"></script>
<script type="text/javascript" src="<?php echo URLPRE;?>static/template/default/mobile/js/dialog.js"></script>
<style>
     html,body{height:100% !important;}
     input::-webkit-input-placeholder{color:#FFF;}
     .listForm {
           margin-top: 0;
     }

     .register-contract-box{width:100%;margin:0 auto;text-align:center;}
     .login-content{height:auto; min-height: 100%;}
</style>
<div class="login-content">
     <div class="login-img">
                <img src="<?php echo URLPRE;?>static/template/weixin/mobile/img/login.png">
     </div>
     <div class="register-title-box" id="js-register-title-box">
           <h1>请输入手机号码</h1>
     </div>
     <form action="" class="listForm" method="post">
        <article class="login-input-box" id="js-register-input-box">
            <section>
                     <input name="Form[account]" placeholder="请输入11位手机号码" type="text" autocomplete="off" class="login-input">
             </section>
            <section>
             <div class="register-code-box">
               <input type="text" maxlength="6" name="Form[code]" placeholder="请输入验证码"   autocomplete="off"  class="register-code-input">
               <a id="js-sendVadecode" class="register-code-button" href="javascript:void(0);">获取验证码</a>
             </div>
             </section>
            <section>
                     <input name="Form[password]" placeholder="设定密码（至少6位密码）"  autocomplete="off" type="password" class="login-input">
             </section>
             <section>
                     <input name="repassword"  placeholder="再次输入密码" type="password"  autocomplete="off" class="login-input">
             </section>

        </article>
         <div class="login-button-box">
            <a href="javascript:void(0);" class="login-button" id="js-register-button" title="点击注册">点击注册</a>
         </div>
     </form>
    <?php if(in_array(SITEID, array(33715))){?>
        <div style="color:#349cd1;padding:10px">
            首次注册会员的用户，可凭手机到本公司领取精美礼品一份，本次活动礼品解释权归本公司所有！
        </div>
    <?php }?>
</div>

<?php $this->load->module('mobile/index/footer', $common);?>
<script type="text/javascript">

    var site_url = '<?php echo site_url();?>';
    function alert_popup(text){
        $.dialog({
            style:'tip',
            width:200,
            closeTime:500,
            content: '<p style="text-align: center">'+text+'</p>'
        }).open();
    }

    var wait=60;
    function time() {
        var o = $('#js-sendVadecode');
        if (wait == 0) {
            o.html("获取验证码");
            wait = 60;
        } else {

            o.addClass("unable");
            o.html("重新发送(" + wait + ")");
            wait--;
            setTimeout(function() {
                    time()
                },
                1000)
        }
    }

    $(function(){

        $.extend({
            is_mobile:function(value){
                if((value.length == 11 && /^(((13[0-9]{1})|(15[0-9]{1})|(14[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/.test(value))){

                    return true;
                }
                return false;
            }
        })

        $('#js-register-input-box').find('input').focus(function(){

            var title = $(this).attr('placeholder');
            $('#js-register-title-box').text(title);
        })

        $('#js-sendVadecode').click(function(){
            if (wait !== 60) {
                return false ;
            }
            if($('input[name="Form[account]"]').val().length == 0){
                alert_popup('请输入11位手机号码');
                return false;
            }else{
                if(!($.is_mobile($('input[name="Form[account]"]').val()))){
                    alert_popup('请输入正确手机号码');
                    return false;
                }
            }
            var account = $('input[name="Form[account]"]').val();
            var type = $(this).attr('type');
            $.post('<?php echo $vade_url ;?>',{
                account: account,
                type:type
            },function(data){
                if(data.status=='1')
                {
                    time();
                    return false;
                }
                alert_popup(data.info);
                return false;
            },'json')

        })

        $('#js-register-button').click(function(){

            if($('input[name="Form[account]"]').val().length == 0){
                alert_popup('请输入11位手机号码');
                return false;
            }else{
                if(!($.is_mobile($('input[name="Form[account]"]').val()))){
                    alert_popup('请输入正确手机号码');
                    return false;
                }
            }
            if($('input[name="Form[code]"]').val().length == 0){
                alert_popup('请输入验证码');
                return false;
            }
            if($('input[name="Form[password]"]').val().length == 0){
                alert_popup('设定密码（至少6位密码）');
                return false;
            }
            if($('input[name="repassword"]').val().length == 0){
                alert_popup('再次输入密码');
                return false;
            }else{
                if($('input[name="repassword"]').val()!== $('input[name="Form[password]"]').val()){
                    alert_popup('两次密码输入不一致');
                    return false;
                }
            }


            var account = $('input[name="Form[account]"]').val();
            var password = $('input[name="Form[password]"]').val();
            var code = $('input[name="Form[code]"]').val();
            $.post('<?php echo $form_url ;?>',{
                account: account,
                password: password,
                code: code
            },function(data){
                if(data.status=='1')
                {
                    if(data.referer.length>0){

                        window.location.href =  site_url+data.referer  ;
                    }
                    window.location.href = '<?php echo site_url('mobile/member/center'); ?>' ;
                }
                alert_popup(data.info);
                return false;
            },'json')
        })
    });
</script>